package com.blog.service.impl;

import com.blog.dao.UserDao;
import com.blog.model.User;
import com.blog.service.UserService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    /**
     * 注入UserMapper接口
     */
    @Autowired
    private UserDao userDao;

    /**
     * 新增用户
     */
    @Override
    public void saveUser(User user) {
        userDao.saveUser(user);
    }

    /**
     * 更新用户
     */
    @Override
    public boolean updateUser(User user) {
        return userDao.updateUser(user);
    }

    /**
     * 根据Id删除用户
     */
    @Override
    public boolean deleteUser(int id) {
        return userDao.deleteUser(id);
    }

    /**
     * 根据id查找用户
     */
    @Override
    public User findUserById(int id) {
        User user = userDao.findUserById(id);
        return user;
    }

    /**
     * 查询所有用户
     */
    @Override
    public List<User> findAll() {
        List<User> allUser = userDao.findAll();
        return allUser;
    }

    /**
     * 登录判断
     * @param account
     * @param password
     * @return
     */
    @Override
    public User getByUser(String account, String password) {
        User byUser = userDao.getByUser(account,password);
        return  byUser;

    }
}
